package org.colafries.admin.controller.index;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.colafries.admin.entity.domain.index.LogicFactTableField;
import org.colafries.admin.entity.vo.index.LogicFactTblFieldReqVO;
import org.colafries.admin.service.index.ILogicFactTableFieldService;
import org.colafries.admin.wrapper.Response;
import org.colafries.admin.wrapper.ResponseWrapper;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Ann
 * @version v1.0
 * @ClassName LogicFactTableFieldController
 * @Description
 * @date Created in 2024/6/5
 **/
@RestController
@RequestMapping("/index/logicFactTableField")
public class LogicFactTableFieldController {

    @Resource
    ILogicFactTableFieldService logicFactTableFieldService;

    /**
     * 添加逻辑事实表字段
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/5
     */
    @PostMapping("/add")
    public Response<?> add(@RequestBody LogicFactTblFieldReqVO reqVO) {
        int result = logicFactTableFieldService.add(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 更新逻辑事实表字段
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/5
     */
    @PostMapping("/update")
    public Response<?> update(@RequestBody LogicFactTblFieldReqVO reqVO) {
        int result = logicFactTableFieldService.update(reqVO);
        return ResponseWrapper.ok(result);
    }


    /**
     * 删除逻辑事实表字段
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/6
     */
    @PostMapping("/delete")
    public Response<?> delete(@RequestBody LogicFactTblFieldReqVO reqVO) {
        int result = logicFactTableFieldService.delete(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 获取逻辑事实表字段 listAll
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/5
     */
    @PostMapping("/listAll")
    public Response<?> listAll(@RequestBody LogicFactTblFieldReqVO reqVO) {
        List<LogicFactTableField> result = logicFactTableFieldService.listAll(reqVO);
        return ResponseWrapper.ok(result);
    }

    /**
     * 分页查询逻辑事实表字段明细
     * @param reqVO
     * @return org.colafries.admin.wrapper.Response<?>
     * @Author anning
     * @Date 2024/6/5
     */
    @PostMapping("/pageList")
    public Response<?> pageList(@RequestBody LogicFactTblFieldReqVO reqVO) {
        IPage<LogicFactTableField> result = logicFactTableFieldService.pageList(reqVO);
        return ResponseWrapper.ok(result);
    }
}
